package com.black.common.util;

public class ComCodeUtil {
    /**
     * 权限机构获取
     * 1.全为0的为总机构
     * 2.按两位数区分同级
     *
     * @param comCode 归属机构代码
     * @return 权限机构
     */
    public static String getPowerComCode(String comCode) {
        if (comCode.matches("[0]+")) {
            return "";
        } else {
            StringBuilder powerComCode = new StringBuilder();
            int i = 2;
            while (i <= comCode.length() && !"00".equals(comCode.substring(i - 2, i))) {
                powerComCode.append(comCode, i - 2, i);
                i = i + 2;
            }
            return powerComCode.toString();
        }
    }
}
